<?php
/**
 * error web view class
 *
 * @author raphael seebacher <raphasee@ee.ethz.ch>
 * @version 0.01
 */
class error_web_view extends error_view {
    protected static $error_messages = Array(
      401 => 'You are not authorized!',
      404 => 'The page you requested does not exist!',
      500 => 'Internal Server Error!',
    );

    protected static function get_error_message($status_code) {
        if (array_key_exists($status_code, self::$error_messages)) {
            return 'Error: '.self::$error_messages[$status_code];
        }
        else {
            return '';
        }
    }

    public function __construct($status_code) {
        $error_message = self::get_error_message($status_code);
        parent::__construct($error_message, $status_code);
    }


    public function send_header() {
        if ($this->http_status != NULL) {
            header('Status: '.$this->http_status);
        }
    }

    public function get_content() {
        $template = file_get_contents('../templates/error.html');

        return str_replace('[error_message]', $this->error_message, $template);
    }
}
?>